//
//  JSSToolBarStatusView.swift
//  WeiBoItem
//
//  Created by jss on 16/4/21.
//  Copyright © 2016年 jss. All rights reserved.
//

import UIKit

class JSSToolBarStatusView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {//commentBtn  likeBtn
        let retweetBtn = addChildBtton("转发", imageName: "timeline_icon_retweet")
        
        let commentBtn = addChildBtton("评论", imageName: "timeline_icon_comment")
        let likeBtn = addChildBtton("赞", imageName: "timeline_icon_unlike")
        
        let sp1 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        
        let sp2 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        
        addSubview(sp1)
        addSubview(sp2)
        
        retweetBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.leading.bottom.equalTo(self)
            make.width.equalTo(likeBtn)
         
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.bottom.equalTo(self)
            make.leading.equalTo(retweetBtn.snp_trailing)
            make.width.equalTo(retweetBtn)
            
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.bottom.trailing.equalTo(self)
            make.leading.equalTo(commentBtn.snp_trailing)
            make.width.equalTo(commentBtn)

        }
        
        sp1.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(retweetBtn.snp_trailing)
            make.centerY.equalTo(retweetBtn.snp_centerY)
        }

        sp2.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commentBtn.snp_trailing)
            make.centerY.equalTo(retweetBtn.snp_centerY)
        }
        
    
    }
    
    
    
    private func addChildBtton(title: String,imageName:String)->UIButton {
        
        //添加三个button
        let button = UIButton(title: title, imageName: imageName, textColor: UIColor.darkGrayColor(), textFont: 14)
        
        //设置图片
        button.setImage(UIImage(named: imageName), forState: .Normal)
        
        //设置背景图片(常规和高亮)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: .Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: .Highlighted)
        
        addSubview(button)
        
        return button
    }
    
    
}
